
package com.work.calculations;

import com.work.db.DaoFactoryImpl;
import com.work.db.dao.*;
import com.work.db.entity.Employer;

public class LeaveCalculations {
	private static LeaveCalculations instance;

	private LeaveCalculations() {
	}
	
	public int getRemainingLeave(Employer employer, int year) {
		LeaveDao leaveDao = DaoFactoryImpl.instance().getLeaveDao();
		Integer remainingLeave = leaveDao.getRemainingLeave(employer, year);
		return remainingLeave != null ? remainingLeave : 0;
	}
	
	public int getOvertimeToTake(Employer employer, int year) {
		OvertimeDao overtimeDao = DaoFactoryImpl.instance().getOvertimeDao();
		Integer remainingLeave = overtimeDao.getOvertimeMinutesToTake(employer, year);
		return remainingLeave != null ? remainingLeave : 0;
	}
	
	public static LeaveCalculations instance() {
		if (instance == null) {
			instance = new LeaveCalculations();
		}
		return instance;
	}
}
